<?php
/**
 * Created by PhpStorm.
 * User: 12133
 * Date: 2022/12/5
 * Time: 13:24
 */

namespace app\controller\sys;


use app\BaseController;
use app\model\sys\SysUser;
use think\App;

class Base extends BaseController
{
    protected $page = 1;
    protected $size = 10;
    protected $start_time = '';
    protected $end_time = '';
    protected $userInfo = null;
    protected $where = [];
    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->page = input('page',1);
        $this->size = input('size',10);
        $this->start_time = input('start_time');
        $this->end_time = input('end_time');
        global $user;
        if (!empty($user->user_id))
            $this->userInfo = SysUser::where('user_id',$user->user_id)->find();
        if ($this->userInfo->role_type == 'kefu')
            $this->where[] = ['kefu_id','=',$this->userInfo->user_id];
    }
    protected function msg($data = [],string $msg = '成功',int $code = 200,int $http_code = 200){
        return json(['code' => $code,'msg' => $msg,'data' => $data],$http_code);
    }
    protected function fail($msg = '失败',$code = 400,$http_code = 200){
        return json(['code' => $code,'msg' => $msg,'data' => []],$http_code);
    }
}